package com.gopay.cron.service.cloud.gen.bean;

import com.gopay.cron.web.vo.CloudAccountStatementVO;

/**
 * Created by Johnson on 2017/3/1.
 */
public class PayFileInfo {

    public static final String fileName = "04";

    public static final String txtFirstLine = "商户订单号\t国付宝账户号\t付款结算类型\t收款方协议号\t交易金额\t手续费\t交易请求时间\t清算时间";
    public static final String csvFirstLine = "\"商户订单号\",\"国付宝账户号\",\"付款结算类型\",\"收款方协议号\",\"交易金额\",\"手续费\",\"交易请求时间\",\"清算时间\"";

    private StringBuilder txtLineContent = new StringBuilder();
    private StringBuilder csvLineContent = new StringBuilder();

    //private int count = 0;

    public void addPayFileLine(CloudAccountStatementVO vo) {
        addTxtFileLine(vo);
        addCsvFileLine(vo);
       // count ++;
    }


    public void addTxtFileLine(CloudAccountStatementVO vo) {
        txtLineContent.append(vo.getMerOrderId()).append("\t")
                .append(vo.getGopayAcct()).append("\t")
                .append(vo.getGopayIntTxnCd()).append("\t")
                .append(vo.getRecvAcctId()).append("\t")
                .append(vo.getMerTxnAmt()).append("\t")
                .append(vo.getOrderFeeAmt()).append("\t")
                .append(vo.getReqTime()).append("\t")
                .append(vo.getTranFinishTime())
                .append("\r\n");
    }

    public void addCsvFileLine(CloudAccountStatementVO vo) {
        csvLineContent.append("\"").append(vo.getMerOrderId()).append("\",")
                .append("\"").append(vo.getGopayAcct()).append("\",")
                .append("\"").append(vo.getGopayIntTxnCd()).append("\",")
                .append("\"").append(vo.getRecvAcctId()).append("\",")
                .append("\"").append(vo.getMerTxnAmt()).append("\",")
                .append("\"").append(vo.getOrderFeeAmt()).append("\",")
                .append("\"").append(vo.getReqTime()).append("\",")
                .append("\"").append(vo.getTranFinishTime()).append("\"")
                .append("\r\n");
    }

    public String getTxtContent() {
        StringBuilder sb = new StringBuilder(PayFileInfo.txtFirstLine);
        sb.append("\r\n").append(txtLineContent.toString());
        //.append("总条数：").append(count).append("条");
        return sb.toString();
    }

    public String getCsvContent() {
        StringBuilder sb = new StringBuilder(PayFileInfo.csvFirstLine);
        sb.append("\r\n").append(csvLineContent.toString());
        //.append("\"总条数：").append(count).append("条\"");
        return sb.toString();
    }
}
